import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
import java.util.ArrayList;
/**
 * Write a description of class Puerta here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Puerta extends Actor
{
private Actor Tocaspider;
private Actor Tocabatman;
    /**
     * Act - do whatever the Puerta wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
       World mundo=getWorld();
        
       Tocaspider=this.getOneObjectAtOffset(0,0,Spiderman.class);
       Tocabatman=this.getOneObjectAtOffset(0,0,Batman.class);
       if(Tocaspider!=null && Tocabatman!=null)
       {
        // RESETEA NIVELES Y SE PASA AL NIVEL DOS.
        ((Mundo)mundo).cambia_nivel(1);
       }
       
       Gravedad();
    }
    
    
      public boolean Gravedad()
    {    
         Actor mosaico;
                           
         List piso =  super.getWorld().getObjectsAt(this.getX(),  this.getY()+70, Plataforma.class);
               if(!piso.isEmpty())
        {
           return (true);
        }
          else
          {
        if (this.getY()<550)
            this.setLocation(this.getX(), this.getY()+5);
            return(false);
          }
    }
}
